 #include<bits/stdc++.h>
#define ls(k) k << 1
#define rs(k) k << 1 | 1
#define fi first
#define se second
#define open(s1, s2) freopen(s1, "r", stdin), freopen(s2, "w", stdout);
using namespace std;
typedef __int128 __;
typedef long double lb;
typedef double db;
typedef unsigned long long ull;
typedef long long ll;
const int M = 1e6 + 10, INF = 1e9;
inline ll read(){
    ll x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9'){
        if(c == '-')
          f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9'){
        x = (x << 1) + (x << 3) + (c ^ 48);
        c = getchar();
    }
    return x * f;
}
inline void write(ll x){
	if(x < 0){
		putchar('-');
		x = -x;
	}
	if(x > 9)
	  write(x / 10);
	putchar(x % 10 + '0');
}
inline char get(){
	char c;
	while(1){
		c = getchar();
		if(c == 'A' || c == 'R')
		  break;
	}
	return c;
}
char op;
int q, l, r;
struct Node{
	int l, r;
	int Max, Min;
	int ans;
}X[M << 2];
multiset<int> L, R;
multiset<int> mxl[M], mnr[M];
inline void pushup(int k){
	X[k].Max = max(X[k << 1].Max, X[k << 1 | 1].Max);
	X[k].Min = min(X[k << 1].Min, X[k << 1 | 1].Min);
	X[k].ans = min({X[k << 1].ans, X[k << 1 | 1].Min - X[k << 1].Max, X[k << 1 | 1].ans});
}
void build(int k, int l, int r){
	X[k].l = l, X[k].r = r;
	if (l == r){
		X[k].ans = X[k].Min = INF;
		X[k].Max = -INF;
		return;
	}
	int mid = (l + r) >> 1;
	build(k << 1, l, mid);
	build(k << 1 | 1, mid + 1, r);
	pushup(k);
}
inline void update(int k, int i){
	if(X[k].l == i && i == X[k].r){
		if(mxl[i].empty())
		  X[k].Max = -INF;
		else
		  X[k].Max = *(--mxl[i].end());
		if(mnr[i].empty())
		  X[k].Min = INF;
		else
		  X[k].Min = *mnr[i].begin();
		X[k].ans = X[k].Min - X[k].Max;
		return ;
	}
	int mid = (X[k].l + X[k].r) >> 1;
	if(i <= mid)
	  update(k << 1, i);
	else
	  update(k << 1 | 1, i);
	pushup(k);
}
int main(){
	open("stone.in", "stone.out");
	q = read();
	build(1, 1, 1e6);
	while(q--){
		op = get(), l = read(), r = read();
		if(op == 'A'){
			L.insert(l);
			R.insert(r);
			mxl[r].insert(l);
			mnr[l].insert(r);
		}
		else{
			L.erase(L.find(l));
			R.erase(R.find(r));
			mxl[r].erase(mxl[r].find(l));
			mnr[l].erase(mnr[l].find(r));
		}
		update(1, l), update(1, r);
		l = *(--L.end()), r = *R.begin();
		if(l < r){
			write(*(mnr[l].lower_bound(r)) - *(--mxl[r].upper_bound(l)));
			putchar('\n');
		}
		else{
			write(X[1].ans);
			putchar('\n');
		}
	}
	return 0;
}
